<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FreeRTOS基础知识 - FreeRTOS学习笔记</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f4f4f4;
        }

        header {
            background: linear-gradient(135deg, #2c3e50, #3498db);
            color: white;
            text-align: center;
            padding: 2rem 0;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        h1 {
            font-size: 2.5rem;
            margin-bottom: 0.5rem;
        }

        .subtitle {
            font-size: 1.2rem;
            opacity: 0.9;
        }

        nav {
            background-color: #2c3e50;
            padding: 0;
            position: sticky;
            top: 0;
            z-index: 100;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        nav ul {
            list-style: none;
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
        }

        nav li {
            margin: 0;
        }

        nav a {
            display: block;
            color: white;
            text-decoration: none;
            padding: 1rem 1.5rem;
            transition: background-color 0.3s;
        }

        nav a:hover {
            background-color: #3498db;
        }

        .container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 0 2rem;
        }

        .content {
            background-color: white;
            border-radius: 8px;
            padding: 2rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        section {
            margin-bottom: 3rem;
        }

        h2 {
            color: #2c3e50;
            border-bottom: 2px solid #3498db;
            padding-bottom: 0.5rem;
            margin-bottom: 1.5rem;
        }

        h3 {
            color: #3498db;
            margin: 1.5rem 0 1rem;
        }

        h4 {
            color: #2c3e50;
            margin: 1rem 0 0.5rem;
        }

        p {
            margin-bottom: 1rem;
        }

        ul, ol {
            margin-left: 2rem;
            margin-bottom: 1rem;
        }

        li {
            margin-bottom: 0.5rem;
        }

        pre {
            background-color: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 4px;
            padding: 1rem;
            overflow-x: auto;
            margin: 1rem 0;
        }

        code {
            font-family: 'Courier New', monospace;
            background-color: #f8f9fa;
            padding: 0.2rem 0.4rem;
            border-radius: 3px;
            font-size: 0.9rem;
        }

        pre code {
            background-color: transparent;
            padding: 0;
        }

        .function-signature {
            background-color: #e8f4fc;
            border-left: 4px solid #3498db;
            padding: 1rem;
            margin: 1rem 0;
            border-radius: 0 4px 4px 0;
        }

        .footer {
            text-align: center;
            padding: 2rem;
            background-color: #2c3e50;
            color: white;
            margin-top: 2rem;
        }

        .nav-links {
            display: flex;
            justify-content: space-between;
            margin-top: 2rem;
        }

        .nav-links a {
            text-decoration: none;
            color: #3498db;
            font-weight: bold;
            padding: 0.5rem 1rem;
            border: 1px solid #3498db;
            border-radius: 4px;
        }

        .nav-links a:hover {
            background-color: #3498db;
            color: white;
        }

        @media (max-width: 768px) {
            nav ul {
                flex-direction: column;
            }
            
            .container {
                padding: 0 1rem;
            }
            
            h1 {
                font-size: 2rem;
            }
        }
    </style>
    <!-- 引入浮动笔记窗口脚本 -->
    <script src="float-notes.js"></script>
</head>
<body>
    <header>
        <h1>FreeRTOS学习笔记</h1>
        <p class="subtitle">第一章：FreeRTOS基础知识</p>
    </header>

    <nav>
        <ul>
            <li><a href="index.html">主页</a></li>
            <li><a href="chapter1.html">基础知识</a></li>
            <li><a href="chapter2.html">任务管理</a></li>
            <li><a href="chapter3.html">任务调度</a></li>
            <li><a href="chapter4.html">内存管理</a></li>
            <li><a href="chapter5.html">队列</a></li>
            <li><a href="chapter6.html">信号量</a></li>
            <li><a href="chapter7.html">软件定时器</a></li>
            <li><a href="image_gallery.html">图片资源</a></li>
        </ul>
    </nav>

    <div class="container">
        <div class="content">
            <section id="introduction">
                <h2>1. FreeRTOS基础知识</h2>
                
                <h3>1.1 任务调度方式</h3>
                
                <h4>抢占式调度</h4>
                <p>抢占式调度是FreeRTOS中最主要的调度方式，基于任务优先级：</p>
                <ul>
                    <li>高优先级任务可以随时抢占低优先级任务的CPU使用权</li>
                    <li>当高优先级任务就绪时，立即进行任务切换</li>
                    <li>保证了高优先级任务的实时性</li>
                </ul>
                
                <h4>时间片调度</h4>
                <p>时间片调度用于相同优先级的任务：</p>
                <ul>
                    <li>每个任务运行一个时间片（通常等于一个SysTick中断周期）</li>
                    <li>时间片结束后自动切换到下一个同优先级任务</li>
                    <li>实现相同优先级任务的"轮流"执行</li>
                </ul>
                
                <h4>协程式调度</h4>
                <p>协程式调度已不推荐使用：</p>
                <ul>
                    <li>任务主动让出CPU控制权</li>
                    <li>不支持抢占，实时性差</li>
                    <li>主要为了兼容性而保留</li>
                </ul>
                
                <h3>1.2 任务状态</h3>
                <p>FreeRTOS中任务有四种基本状态：</p>
                
                <h4>运行态</h4>
                <ul>
                    <li>正在执行的任务</li>
                    <li>在单核系统中，任何时候只有一个任务处于运行态</li>
                </ul>
                
                <h4>就绪态</h4>
                <ul>
                    <li>任务已准备好运行，但未被调度器选中</li>
                    <li>就绪任务存储在就绪列表中，按优先级排列</li>
                </ul>
                
                <h4>阻塞态</h4>
                <ul>
                    <li>任务因等待事件或延时而暂停执行</li>
                    <li>可分为延时阻塞和事件阻塞</li>
                    <li>阻塞任务存储在阻塞列表中</li>
                </ul>
                
                <h4>挂起态</h4>
                <ul>
                    <li>任务被显式挂起，不参与调度</li>
                    <li>需要显式恢复才能进入就绪态</li>
                    <li>挂起任务存储在挂起列表中</li>
                </ul>
            </section>
            
            <div class="nav-links">
                <a href="index.html">上一章：首页</a>
                <a href="chapter2.html">下一章：任务管理</a>
            </div>
        </div>
    </div>

    <footer class="footer">
        <p>FreeRTOS学习笔记 &copy; 2025</p>
        <p>作者: zou.commit()</p>
    </footer>
</body>
</html>